package com.example.redissiontest.enpoint;

import com.example.redissiontest.config.DistributedLock;
import com.example.redissiontest.entity.Ticket;
import com.example.redissiontest.service.TicketService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author Lay
 * @description
 * @date 2023年04月23日 16:02
 */
@RestController
@RequestMapping("/ticket")
@RequiredArgsConstructor
@Slf4j
public class TicketEndpoint {
    private final TicketService ticketService;

    @PostMapping("buy")
    public Long buy() {
        return ticketService.deduct(1L);
    }
}
